package com.gko100.dao.impl;

import java.util.List;

import com.gko100.dao.DiseaseDao;

import com.gko100.dao.basehibernatesupport.BaseHibernateDaoSupport;


import com.gko100.model.Disease;
import com.gko100.model.Language;



public class DiseaseDaoHibernate extends BaseHibernateDaoSupport implements DiseaseDao {

	/* 
	 * {见接口方法说明}
	 */
	public void delDisease(Disease dis) {
		
		this.getHibernateTemplate().delete(dis);
		
	}
	
	/* 
	 * {见接口方法说明}
	 */
	public Disease findDisByTitle(String title) {
		
		List<Disease> disList = this.getHibernateTemplate().find("from Disease as d where d.title=?", title);
		if(disList!=null&&disList.size()>=1){
			
			return disList.get(0);
			
		}
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public List<Disease> findDisListByDisPid(Integer disPid) {
		
		List<Disease> disList = this.getHibernateTemplate().find("from Disease as d where d.disPid=?", disPid);
		if(disList!=null&&disList.size()>=1){
			
			return disList;
			
		}
		
		return null;
	}

	
	
	/* 
	 * {见接口方法说明}
	 */
	public List<Disease> findDisListByDisPidAndLang(Integer disPid, Language lang) {
		
		List<Disease> disList = this.getHibernateTemplate().find("from Disease as d where d.disPid=? and d.lang=?", disPid, lang);
		if(disList!=null&&disList.size()>=1){
			
			return disList;
			
		}
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public Disease findDisByDisId(Integer diseaseId) {
		
		Disease dis = this.getHibernateTemplate().get(Disease.class, diseaseId);
		
		if(dis!=null){
			return dis;
		}
		return null;
	}

	/* 
	 * {见接口方法说明}
	 */
	public void saveDisease(Disease dis) {
		
		this.getHibernateTemplate().save(dis);
		
	}

	/* 
	 * {见接口方法说明}
	 */
	public void updateDisease(Disease dis) {
		
		this.getHibernateTemplate().update(dis);
		
	}
	
	

	
	
}
